package com.imedical.controller;

import com.imedical.entity.RequestDetail;
import com.imedical.enums.SendRequestEnum;
import com.imedical.strategy.SendRequestFactory;
import com.imedical.util.R;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2022/5/12
 */
@Api(tags = "接口调用")
@RestController
public class DocumentController {

    @ApiOperation(value = "接口调用")
    @RequestMapping(value = "data/third", method = {RequestMethod.GET, RequestMethod.POST})
    public Object sendRequest(RequestDetail requestDetail) {
        // 判断调用接口类型
        if (StrUtil.isNotBlank(requestDetail.getRequestType())) {
            return SendRequestFactory.getStrategy(SendRequestEnum.get(requestDetail.getRequestType())).sendRequest(requestDetail);
        }
        return R.failed();
    }
}
